package com.qf.ability.message.entity;

import io.netty.channel.Channel;
import lombok.Data;
import lombok.experimental.Accessors;
import org.kurento.client.WebRtcEndpoint;

import java.io.Serializable;

/**
 * 用户对象
 * author Ken
 * create_time 2022/10/17
 */
@Data
@Accessors(chain = true)
public class UserSession implements Serializable {

    private Integer uid;
    private String role;//master - 主播 slave - 观看者
    private String nickname; //昵称
    private String header; //头像
    private Channel channel; //管道对象
    private WebRtcEndpoint webRtcEndpoint;//媒体端点

    /**
     * 回收资源
     */
    public void release(){
        if (channel != null){
            channel.close();
        }

        if (webRtcEndpoint != null) {
            webRtcEndpoint.release();
        }
    }
}
